package time;


import java.time.Instant;

/**
 * 时间戳测试
 */
public class InstantTest {
    public static void main(String[] args) {
        now();
        alter();
    }

    private static void alter() {
        Instant now = Instant.now();
        Instant plusSeconds = now.plusSeconds(20);
        Instant minusSeconds = now.minusSeconds(20);
        System.out.println("now = " + now);
        System.out.println("plusSeconds = " + plusSeconds);
        System.out.println("minusSeconds = " + minusSeconds);
    }

    private static void now() {
        // 内部保存了秒和纳秒，一般不是给用户使用的，而是方便程序做统计用的
        Instant now = Instant.now();
        System.out.println("now = " + now);
    }
}
